home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue17 / source / RCScreen.sl < prev    next >
Encoding:
Text File  |  2002-08-14  |  725 b   |  27 lines

  1. /* 
  2.  * screen(): surface shader for giving "wireframe" appearance. The method is
  3.   *    to render the surface opaque within a small distance of a grid in s,t
  4.   *    space. The grid is derived from a modulus function.
  5.  */
  6. surface 
  7. RCScreen(
  8.     float Ks   = .5, 
  9.     Kd         = .5, 
  10.     Ka         = .1, 
  11.     roughness  = .1,
  12.     density    = .25,
  13.     frequency  = 20;
  14.     color   specularcolor = color (1,1,1) )
  15. {
  16.    varying point Nf = faceforward( normalize(N), I );
  17.    point V = normalize(-I);
  18.  
  19.    if( mod(s*frequency,1) < density || mod(t*frequency,1) < density)
  20.       Oi = 1.0;
  21.    else 
  22.       Oi = 0.0;
  23.  
  24.    Ci = Oi * ( Cs * ( Ka*ambient() + Kd*diffuse(Nf) ) + 
  25.             specularcolor*Ks*specular(Nf,V,roughness));
  26. }
  27.